package bairui.international.weixin.portal.miniapp.controller.branchCompany.staff;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_BranchCompanyStaff;
import bairui.international.model.domain.jpa.TB_User;
import bairui.international.service.Service_BranchCompanyStaff;
import bairui.international.service.Service_BranchCompanyStaffWithdrawOrder;
import bairui.international.service.Service_User;
import lombok.Getter;
import lombok.Setter;

/**
 *
 * 提现审核不通过
 *
 * @generated
 * 
 * @see STest_C_BranchCompnay_Staff_WithdrawVerifyNoPass_Post 测试
 *
 */
@Controller
public class C_BranchCompnay_Staff_WithdrawVerifyNoPass_Post
 extends SC_BranchCompnay_Staff_WithdrawVerifyNoPass_Post 
{
	
	@Autowired private Service_User service_User;
	@Autowired private Service_BranchCompanyStaff service_BranchCompanyStaff;
	@Autowired private Service_BranchCompanyStaffWithdrawOrder service_BranchCompanyStaffWithdrawOrder;
	
	/**
	 * Post请求
	 */
	@Action(Post.class)
	@PostMapping(Post.RequestMappingValue)
	public @FomatOutput @ResponseBody Object post(
		ModelMap map, HttpServletRequest request,
		@RequestParam String skey,
		@RequestBody Input input,
		@PathVariable(name=Post.PathVariableName.Id) long id
	) throws Exception {
		TB_User user = service_User.findOne(it->it.skey.eq(skey));
		TB_BranchCompanyStaff branchCompanyStaff = service_BranchCompanyStaff.getActive(user);
		if(branchCompanyStaff.getDirectorFlag()){
			service_BranchCompanyStaffWithdrawOrder.vertifyNoPass(id, branchCompanyStaff, input.getMessage());
		}
		return null;
	}
	
	public static class Input {
		private @Getter @Setter String message;
	}

}
